-
Notifications
You must be signed in to change notification settings - Fork 6k
Restructure VB.NET async article to follow C# breakfast tutorial format with proper VB syntax #48186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: BillWagner <[email protected]>
@copilot You picked the wrong C# article as a source. Use the one referenced in this comment: #17731 (comment) The correct article is this one: https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/ You can reuse those images for the VB article as well. |
Co-authored-by: BillWagner <[email protected]>
I've restructured the VB article to follow the correct C# article format using the breakfast tutorial approach. The article now uses the same progressive teaching structure (synchronous → simple async → concurrent async) but with proper VB.NET syntax throughout. All code examples have been converted to the breakfast metaphor with VB.NET conventions. Commit: 07fcef0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much closer. I have a few things to address and this will be ready.
docs/visual-basic/programming-guide/concepts/async/snippets/breakfast/breakfast.vbproj
Outdated
Show resolved
Hide resolved
@copilot Please address the remaining comments. |
…t, add C# diagrams Co-authored-by: BillWagner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once I upgrade to .NET 9, this is ready.
docs/visual-basic/programming-guide/concepts/async/snippets/breakfast/breakfast.vbproj
Outdated
Show resolved
Hide resolved
…eakfast/breakfast.vbproj
|
||
The suspension of an async method at an `Await` expression doesn't constitute an exit from the method, and `Finally` blocks don't run. | ||
Notice that quite a few tasks finish between the time when the toaster catches fire and the system observes the exception. When a task that runs asynchronously throws an exception, that task is **faulted**. The <xref:System.Threading.Tasks.Task> object holds the exception thrown in the <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property. Faulted tasks throw an exception when the `Await` expression is applied to the task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that quite a few tasks finish between the time when the toaster catches fire and the system observes the exception. When a task that runs asynchronously throws an exception, that task is **faulted**. The <xref:System.Threading.Tasks.Task> object holds the exception thrown in the <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property. Faulted tasks throw an exception when the `Await` expression is applied to the task. | |
Notice that quite a few tasks finish between the time when the toaster catches fire and the system observes the exception. When a task that runs asynchronously throws an exception, that task is **faulted**. The <xref:System.Threading.Tasks.Task> object holds the exception that was thrown in the <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property. Faulted tasks *throw* the exception when the `Await` expression is applied to the task. |
- How an exception is stored in a faulted task | ||
- How an exception is unpackaged and rethrown when code waits (`Await`) on a faulted task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- How an exception is stored in a faulted task | |
- How an exception is unpackaged and rethrown when code waits (`Await`) on a faulted task | |
- How an exception is stored in a faulted task. | |
- How an exception is unpackaged and rethrown when code waits (`Await`) on a faulted task. |
|
||
`Async` and `Await` are contextual keywords. For more information and examples, see the following topics: | ||
When code running asynchronously throws an exception, the exception is stored in the <xref:System.Threading.Tasks.Task> object. The <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property is a <xref:System.AggregateException> object because more than one exception might be thrown during asynchronous work. Any exception thrown is added to the <xref:System.AggregateException.InnerExceptions?displayProperty=nameWithType> collection. If the `Exception` property is null, a new `AggregateException` object is created and the thrown exception is the first item in the collection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When code running asynchronously throws an exception, the exception is stored in the <xref:System.Threading.Tasks.Task> object. The <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property is a <xref:System.AggregateException> object because more than one exception might be thrown during asynchronous work. Any exception thrown is added to the <xref:System.AggregateException.InnerExceptions?displayProperty=nameWithType> collection. If the `Exception` property is null, a new `AggregateException` object is created and the thrown exception is the first item in the collection. | |
When code running asynchronously throws an exception, the exception is stored in the <xref:System.Threading.Tasks.Task> object. The <xref:System.Threading.Tasks.Task.Exception?displayProperty=nameWithType> property is an <xref:System.AggregateException> object because more than one exception might be thrown during asynchronous work. Any exception thrown is added to the <xref:System.AggregateException.InnerExceptions?displayProperty=nameWithType> collection. If the `Exception` property is null, a new `AggregateException` object is created and the thrown exception is the first item in the collection. |
|
||
## <a name="BKMK_ReturnTypesandParameters"></a> Return types and parameters | ||
> [!TIP] | ||
> The recommended practice is for any argument validation exceptions to emerge *synchronously* from task-returning methods. For more information and examples, see [Exceptions in task-returning methods](/dotnet/fundamentals/exceptions/creating-and-throwing-exceptions#exceptions-in-task-returning-methods). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> The recommended practice is for any argument validation exceptions to emerge *synchronously* from task-returning methods. For more information and examples, see [Exceptions in task-returning methods](/dotnet/fundamentals/exceptions/creating-and-throwing-exceptions#exceptions-in-task-returning-methods). | |
> The recommended practice is for any argument validation exceptions to emerge *synchronously* from task-returning methods. For more information and examples, see [Exceptions in task-returning methods](../../../../fundamentals/exceptions/creating-and-throwing-exceptions.md#exceptions-in-task-returning-methods). |
Console.WriteLine("Fire! Toast is ruined!") | ||
Throw New InvalidOperationException("The toaster is on fire") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Console.WriteLine("Fire! Toast is ruined!") | |
Throw New InvalidOperationException("The toaster is on fire") | |
' Console.WriteLine("Fire! Toast is ruined!") | |
' Throw New InvalidOperationException("The toaster is on fire") |
The Visual Basic async programming documentation was using an incorrect C# article as a reference and had an academic structure that didn't match the recommended tutorial approach. This PR completely restructures the VB.NET async article to follow the correct C# article format (https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/) while using proper Visual Basic syntax throughout.
Key Changes
Complete structural overhaul:
VB.NET breakfast tutorial implementation:
Task(Of T)
,Async Function
,Await
,Module
, etc.Improved consistency and readability:
Modern .NET alignment:
Async
/Await
andContinueWith
patterns in VB.NETEnhanced documentation format:
:::code
format for better renderingThe article now provides the same high-quality tutorial experience as the C# version but with proper Visual Basic syntax and conventions throughout, eliminating the confusion reported in issue #17731.
Fixes #17731.
Fixes #37289 (duplicate).
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews